package homework.day04;

import java.util.Arrays;
import java.util.Random;

/**
 * @author ThinkBook
 */
public class Test07 {
    public static void main(String[] args) {

//创建存放验证码的数组
        char[] validateCode = new char[4];
//创建存放大小写字母以及数字数组
        char[] data = new char[62];
//给data输出添加元素值，提示：通过循环实现
            int i =0;
        // 添加大写字母
            for (char ch = 'A'; ch <= 'Z'; ch++) {
                data[i++] = ch;
            }
        // 添加小写字母
            for (char ch = 'a'; ch <= 'z'; ch++) {
                data[i++] = ch;
            }
        // 添加数字
            for (char ch = '0'; ch <= '9'; ch++) {
                data[i++] = ch;
            }
//循环遍历，为存放验证码的数组每个位置赋值，并输出验证码
        for (int j = 0; j < validateCode.length; j++) {
            Random r = new Random();
            int n= r.nextInt(62-1+1)+1;
            validateCode[j] = data[n];
        }
        //输出验证码
        System.out.println("验证码内容："+
                Arrays.toString(validateCode));
    }
}
